package com.chenan.controller;

import com.chenan.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.*;

/**
 * @Author: 陈安
 * @Date: 2020/12/11$ 20:10$
 * @Description: $todo$
 * @Version 1.0
 */
@Controller
@RequestMapping("/demo")
public class demoController {

    @GetMapping("/test")
    public String test(Model model,String id){
        System.out.println(id);
        List<User> users=new ArrayList<>();
        users.add(new User(1,"张三","深圳"));
        users.add(new User(2,"李四","北京"));
        users.add(new User(3,"王五","武汉"));
        model.addAttribute("userList",users);

        Map<String,Object> dataMap = new HashMap<String,Object>();
        dataMap.put("No","123");
        dataMap.put("address","深圳");
        model.addAttribute("dataMap",dataMap);

        String[] names = {"张三","李四","王五"};
        model.addAttribute("names",names);

        model.addAttribute("nowdate",new Date());

        model.addAttribute("age",22);

        model.addAttribute("hello","cehnan1");
        return "demo";
    }

}
